﻿namespace Web.Control.WWW.Session
{
    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using Model.WWW_User.Teach;
    using BLF.WWW_User.Teach;
    using Lx.Web.Common.ControlsUI;
    using System.Collections.Generic;
    using System.Collections;
    using Model.WWW_User.User;
    public class sessionStateB : BaseControl
    {
        protected string Memberno = "";
        protected long sid = -1;
        protected SessionsModel sm = null;
        protected string Nationality = "";
        protected int sessioncount = 0;
        protected bool isshow = false;
        protected string PayDetail = System.Configuration.ConfigurationManager.AppSettings["PayDetail"];
        protected override void OnLoad(EventArgs e)
        {
            Memberno = HttpContext.Current.User.Identity.Name;
            ArrayList arrylist = new ArrayList();
            if (Memberno == "")
            {
                Page.Response.Redirect("/user/login.htm?ReturnUrl=" + Page.Request.Url.AbsoluteUri);
                return;
            }
            if (!string.IsNullOrEmpty(Request["sid"]))
            {
                long.TryParse(Request["sid"], out sid);
            }
            else
            {
                Response.End();
            }
          
                arrylist = Teach.GetSessionsStateB(sid, Memberno);
                if (arrylist != null && arrylist.Count > 0)
                {
                    sm = arrylist[0] as SessionsModel;
                    if (sm.SessionID == sid) { isshow = true; }
                    if (isshow)
                    {
                        Nationality = (string)arrylist[1];
                        sessioncount = (int)arrylist[2];
                    }
                    
                }
                else
                {
                    Response.End();
                }
            base.OnLoad(e);
        }
        protected string GetPayID(long sid)
        {
            string pid = Teach.GetPayId(sid);
            if (pid != "")
            {
                return "<a href='" + string.Format(PayDetail, sid) + "'>" + pid + "</a>";
            }
            else
            {
                return "";
            }
        }
    }
}